package cliente.gui;

import cliente.Cliente;
import cliente.auxiliar.GereOperacoes;
import cliente.domain.Status;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Iface.java
 *
 * Created on 16/Dez/2009, 3:57:05
 */
/**
 *
 * @author Daniel
 */
public class Iface extends javax.swing.JFrame {

    GereOperacoes gestor = null;

    /** Creates new form Iface */
    public Iface(GereOperacoes gestor) {
        this.gestor = gestor;
        initComponents();
        myTwitterPanel.setVisible(false);
        stateLog.setVisible(false);
        this.listTextTweet.setVisible(false);
    }

    public GereOperacoes getGestor() {
        return gestor;
    }

    public void setGestor(GereOperacoes gestor) {
        this.gestor = gestor;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        myTwitterPanel = new javax.swing.JTabbedPane();
        twitterPanel = new javax.swing.JPanel();
        jTextField3 = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        tweetButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        timelineTXT = new javax.swing.JTextArea();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        stopFollowingButton = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        followingLIST = new javax.swing.JList();
        jScrollPane3 = new javax.swing.JScrollPane();
        followersLIST = new javax.swing.JList();
        refreshButton = new javax.swing.JButton();
        logoutButton = new javax.swing.JButton();
        searchPanel = new javax.swing.JPanel();
        userTXT = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        searchButton = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        followButton = new javax.swing.JButton();
        nameLabel = new javax.swing.JLabel();
        localLabel = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        searchedList = new javax.swing.JList();
        jScrollPane5 = new javax.swing.JScrollPane();
        listTextTweet = new javax.swing.JTextArea();
        jButton2 = new javax.swing.JButton();
        titlePanel = new javax.swing.JLabel();
        stateLog = new javax.swing.JLabel();
        loginPanel = new javax.swing.JTabbedPane();
        login = new javax.swing.JPanel();
        jTextField1 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jPasswordField1 = new javax.swing.JPasswordField();
        jPanel1 = new javax.swing.JPanel();
        pinCode = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        usernameTXT = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel4.setText("Tweet:");

        tweetButton.setText("Tweet");
        tweetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tweetButtonActionPerformed(evt);
            }
        });

        timelineTXT.setColumns(20);
        timelineTXT.setEditable(false);
        timelineTXT.setLineWrap(true);
        timelineTXT.setRows(5);
        timelineTXT.setWrapStyleWord(true);
        jScrollPane1.setViewportView(timelineTXT);

        jLabel5.setText("Following:");

        jLabel6.setText("Followers:");

        jLabel7.setText("Timeline:");

        stopFollowingButton.setText("Stop following");
        stopFollowingButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stopFollowingButtonActionPerformed(evt);
            }
        });

        jScrollPane2.setViewportView(followingLIST);

        jScrollPane3.setViewportView(followersLIST);

        refreshButton.setText("Refresh");
        refreshButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                refreshButtonActionPerformed(evt);
            }
        });

        logoutButton.setText("Logout");
        logoutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logoutButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout twitterPanelLayout = new javax.swing.GroupLayout(twitterPanel);
        twitterPanel.setLayout(twitterPanelLayout);
        twitterPanelLayout.setHorizontalGroup(
            twitterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, twitterPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(twitterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, twitterPanelLayout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 611, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, twitterPanelLayout.createSequentialGroup()
                        .addComponent(refreshButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel7))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 649, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(twitterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(jLabel5)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE)
                    .addComponent(stopFollowingButton, javax.swing.GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, twitterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(logoutButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(tweetButton, javax.swing.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE))
                .addContainerGap())
        );
        twitterPanelLayout.setVerticalGroup(
            twitterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(twitterPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(twitterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(tweetButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(twitterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(refreshButton, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(logoutButton, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(twitterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, twitterPanelLayout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(stopFollowingButton))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE))
                .addContainerGap())
        );

        myTwitterPanel.addTab("Twitter", twitterPanel);

        jLabel8.setText("Username:");

        searchButton.setText("Search");
        searchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchButtonActionPerformed(evt);
            }
        });

        jLabel11.setText("Users:");

        followButton.setText("Follow");
        followButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                followButtonActionPerformed(evt);
            }
        });

        nameLabel.setText("Name: <name>");

        localLabel.setText("Local: <local>");

        searchedList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        searchedList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                searchedListValueChanged(evt);
            }
        });
        jScrollPane4.setViewportView(searchedList);

        listTextTweet.setColumns(20);
        jScrollPane5.setViewportView(listTextTweet);

        jButton2.setText("Tweets");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout searchPanelLayout = new javax.swing.GroupLayout(searchPanel);
        searchPanel.setLayout(searchPanelLayout);
        searchPanelLayout.setHorizontalGroup(
            searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(searchPanelLayout.createSequentialGroup()
                .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(searchPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(searchPanelLayout.createSequentialGroup()
                                .addComponent(jLabel8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(userTXT, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(searchButton))
                            .addComponent(jLabel11)
                            .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jButton2)
                                .addGroup(searchPanelLayout.createSequentialGroup()
                                    .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(followButton)
                                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGap(127, 127, 127)
                                    .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 414, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addGroup(searchPanelLayout.createSequentialGroup()
                        .addGap(37, 37, 37)
                        .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(localLabel)
                            .addComponent(nameLabel))))
                .addContainerGap(29, Short.MAX_VALUE))
        );
        searchPanelLayout.setVerticalGroup(
            searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, searchPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(userTXT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(searchButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel11)
                .addGap(5, 5, 5)
                .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nameLabel)
                    .addComponent(jButton2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(localLabel)
                .addGap(18, 18, 18)
                .addComponent(followButton)
                .addGap(23, 23, 23))
        );

        myTwitterPanel.addTab("Search", searchPanel);

        titlePanel.setFont(new java.awt.Font("Tahoma", 3, 24)); // NOI18N
        titlePanel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        titlePanel.setText("MyTwitter");

        stateLog.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        stateLog.setForeground(new java.awt.Color(255, 0, 0));
        stateLog.setText("Dados incorrectos");

        jLabel1.setText("Username:");

        jLabel2.setText("Password:");

        jButton1.setText("Login");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jButton1MouseReleased(evt);
            }
        });
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout loginLayout = new javax.swing.GroupLayout(login);
        login.setLayout(loginLayout);
        loginLayout.setHorizontalGroup(
            loginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(loginLayout.createSequentialGroup()
                .addGroup(loginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton1)
                    .addGroup(loginLayout.createSequentialGroup()
                        .addGroup(loginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(loginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 135, Short.MAX_VALUE)
                            .addComponent(jPasswordField1, 0, 0, Short.MAX_VALUE))))
                .addContainerGap())
        );
        loginLayout.setVerticalGroup(
            loginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(loginLayout.createSequentialGroup()
                .addContainerGap(16, Short.MAX_VALUE)
                .addGroup(loginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(loginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1))
        );

        loginPanel.addTab("Login", login);

        jLabel3.setText("Username:");

        jLabel9.setText("PinCode:");

        usernameTXT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                usernameTXTActionPerformed(evt);
            }
        });

        jButton3.setText("Get pin");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setText("Login");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(usernameTXT, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
                            .addComponent(pinCode, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)))
                    .addComponent(jButton3)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap(134, Short.MAX_VALUE)
                        .addComponent(jButton4)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(usernameTXT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pinCode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
                .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        loginPanel.addTab("OAuth", jPanel1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(28, 28, 28)
                        .addComponent(myTwitterPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 807, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(titlePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(486, 486, 486))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(stateLog)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addComponent(loginPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(titlePanel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(stateLog))
                    .addComponent(loginPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
                .addComponent(myTwitterPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseReleased
        // TODO add your handling code here:
}//GEN-LAST:event_jButton1MouseReleased

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:

        String nickname = jTextField1.getText();
        String password = jPasswordField1.getText();
        gestor.doLogin(nickname, password);

        if (gestor.getArquivador().isLog_ok()) {
            this.stateLog.setVisible(false);
            loginPanel.setVisible(false);
            myTwitterPanel.setVisible(true);
            gestor.getArquivador().setNickname(nickname);
            gestor.getArquivador().setPassword(password);

            //System.out.println("Nickname:"+gestor.getArquivador().getNickname());
            Status[] aux = gestor.showTweets();
            timelineTXT.setText("");
            for (int i = 0; i < aux.length; i++) {
                timelineTXT.append(aux[i].getName() + "      " + aux[i].getCreatedAt() + "\n" + aux[i].getText() + "\n\n");
            }

            followersLIST.setListData(gestor.showFollowers());
            followingLIST.setListData(gestor.showFollowing());
        } else {
            stateLog.setVisible(true);
            myTwitterPanel.setVisible(false);
        }

    }//GEN-LAST:event_jButton1ActionPerformed

    private void tweetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tweetButtonActionPerformed
        // TODO add your handling code here:
        String tweet = jTextField3.getText();
        gestor.doTweet(tweet);
        System.out.println("tweet enviado:" + tweet);
        jTextField3.setText("");
        Status[] aux = gestor.showTweets();
        timelineTXT.setText("");
        for (int i = 0; i < aux.length; i++) {
            timelineTXT.append(aux[i].getName() + "      " + aux[i].getCreatedAt() + "\n" + aux[i].getText() + "\n\n");
        }
    }//GEN-LAST:event_tweetButtonActionPerformed

    private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshButtonActionPerformed
        // TODO add your handling code here:
        Status[] aux = gestor.showTweets();
        timelineTXT.setText("");
        for (int i = 0; i < aux.length; i++) {
            timelineTXT.append(aux[i].getName() + "      " + aux[i].getCreatedAt() + "\n" + aux[i].getText() + "\n\n");
        }

        followersLIST.setListData(gestor.showFollowers());
        followingLIST.setListData(gestor.showFollowing());
    }//GEN-LAST:event_refreshButtonActionPerformed

    private void stopFollowingButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopFollowingButtonActionPerformed
        // TODO add your handling code here:
        System.out.println("following list chosen: " + followingLIST.getSelectedValue().toString());
        gestor.stopFollowing(followingLIST.getSelectedValue().toString());
        followingLIST.setListData(gestor.showFollowing());
    }//GEN-LAST:event_stopFollowingButtonActionPerformed

    private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchButtonActionPerformed
        // TODO add your handling code here:
        this.listTextTweet.setText("");
        String userSearch = userTXT.getText();
        searchedList.setListData(gestor.search(userSearch));
    }//GEN-LAST:event_searchButtonActionPerformed

    private void logoutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutButtonActionPerformed
        // TODO add your handling code here:
        myTwitterPanel.setVisible(false);
        gestor.doLogout();
        loginPanel.setVisible(true);
        jPasswordField1.setText("");

    }//GEN-LAST:event_logoutButtonActionPerformed

    private void searchedListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_searchedListValueChanged
        // TODO add your handling code here:
        this.listTextTweet.setText("");
        //System.out.println("\n\n---------Nome:"+searchedList.getSelectedValue().toString());
        String[] aux = gestor.showUserDetails(searchedList.getSelectedValue().toString());
        //
        if (aux != null) {
            nameLabel.setText("Name: " + aux[0]);
            if (aux[1] == null) {
                aux[1] = "Nao definido";
            }
            localLabel.setText("Local: " + aux[1]);
        }

    }//GEN-LAST:event_searchedListValueChanged

    private void followButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_followButtonActionPerformed
        // TODO add your handling code here:
        System.out.println("search list chosen: " + searchedList.getSelectedValue().toString());
        gestor.followSomeone(searchedList.getSelectedValue().toString());
    }//GEN-LAST:event_followButtonActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        String nome = searchedList.getSelectedValue().toString();
        //System.out.println("--->Nome:"+searchedList.getSelectedValue().toString());

        Status[] listaTweets = gestor.searchTweets(nome);
        //System.out.println("--->numero de tweets de pesquisa:"+listaTweets.length);
        if (listaTweets != null) {
            listTextTweet.setText("");
            for (int i = 0; i < listaTweets.length; i++) {
                listTextTweet.append(listaTweets[i].getText() + "\n\n");
            }
        }

    }//GEN-LAST:event_jButton2ActionPerformed

    private void usernameTXTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_usernameTXTActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_usernameTXTActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        Cliente.setAuth();
        gestor.doLoginOAuth();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        this.stateLog.setVisible(false);
        loginPanel.setVisible(false);
        myTwitterPanel.setVisible(true);
        gestor.getArquivador().setNickname(usernameTXT.getText());
        gestor.getArquivador().setPassword(pinCode.getText());
        System.out.println("password: "+gestor.getArquivador().getPassword());
        gestor.finishLoginOAuth();
        Status[] aux = gestor.showTweets();
        timelineTXT.setText("");
        for (int i = 0; i < aux.length; i++) {
            timelineTXT.append(aux[i].getName() + "      " + aux[i].getCreatedAt() + "\n" + aux[i].getText() + "\n\n");
        }

        followersLIST.setListData(gestor.showFollowers());
        followingLIST.setListData(gestor.showFollowing());
        
    }//GEN-LAST:event_jButton4ActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton followButton;
    private javax.swing.JList followersLIST;
    private javax.swing.JList followingLIST;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextArea listTextTweet;
    private javax.swing.JLabel localLabel;
    private javax.swing.JPanel login;
    private javax.swing.JTabbedPane loginPanel;
    private javax.swing.JButton logoutButton;
    private javax.swing.JTabbedPane myTwitterPanel;
    private javax.swing.JLabel nameLabel;
    private javax.swing.JTextField pinCode;
    private javax.swing.JButton refreshButton;
    private javax.swing.JButton searchButton;
    private javax.swing.JPanel searchPanel;
    private javax.swing.JList searchedList;
    private javax.swing.JLabel stateLog;
    private javax.swing.JButton stopFollowingButton;
    private javax.swing.JTextArea timelineTXT;
    private javax.swing.JLabel titlePanel;
    private javax.swing.JButton tweetButton;
    private javax.swing.JPanel twitterPanel;
    private javax.swing.JTextField userTXT;
    private javax.swing.JTextField usernameTXT;
    // End of variables declaration//GEN-END:variables
}
